//
//  HTTitleView.m
//  TruckDriver
//
//  Created by Ting Han on 2017/9/26.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "HTTitleView.h"


@interface HTTitleView()
@property (nonatomic,strong) UILabel *label;
@property (nonatomic,strong) NSString *title;
@end

@implementation HTTitleView
- (instancetype)initWithFrame:(CGRect)frame withTitle:(NSString *)title{
    self = [self initWithFrame:frame];
    if (self) {
        self.title = [NSString stringWithFormat:@"  %@  ",title] ;
        [self setupSub];
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
    }
    return self;
}
- (void)setupSub{
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 0, 30)];
    self.label.text = self.title;
    self.label.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.label];
    self.label.textColor = [UIColor lightGrayColor];
    [self.label sizeToFit];
    self.label.center = CGPointMake(self.center.x, self.center.y);
    CGRect rectLabel = self.label.frame;
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(10, 0, rectLabel.origin.x - 10, 0.5f)];
    view1.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:view1];
    UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(rectLabel.origin.x+rectLabel.size.width, 0, rectLabel.origin.x-10, 0.5f)];
    view2.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:view2];
    view1.center = CGPointMake(view1.center.x, self.label.center.y);
    view2.center =  CGPointMake(view2.center.x, self.label.center.y);
   
}

@end
